﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ECCSystem.BizRule
{ 
    class ClsUserMaintenance
    {
        DataAccess.ClsUserMaintenance objDAUM = new ECCSystem.DataAccess.ClsUserMaintenance();
        public ClsUserMaintenance()
        { }

        //Get User List
        public object GetList()
        {
            return objDAUM.GetList();
        }

        //
        public int AddUser(string strLoginID,string strLogonName,string strUserRole,string strUserName)
        {
            
            return objDAUM.AddUser(strLoginID, strLogonName, strUserRole, strUserName,BizRule.ClsCommon.gStrOperator);
        }

        //
        public int EditUser(long lngID, string strLoginID, string strLogonName, string strUserRole, string strUserName)
        {
            return objDAUM.EditUser(lngID, strLoginID, strLogonName, strUserRole, strUserName, BizRule.ClsCommon.gStrOperator);
        }

		public int EditUser(string strIP)
		{
			return objDAUM.EditUser(BizRule.ClsCommon.gStrOperator, strIP);
		}

        //
        public int DeleteUser(long lngID)
        {
            return objDAUM.DeleteUser(lngID,BizRule.ClsCommon.gStrOperator);
        }

        //Check the user who loginID is strLoginID is existence or not
        public bool CheckUserLoginID(long lngID,string strLoginID)
        {
            int intRowsAffected = 0;
            intRowsAffected = objDAUM.CheckUserLoginID(lngID,strLoginID);
            if (intRowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        //Check the user who logonName is stringLogonName is existence or not
        public bool CheckUserLogonName( string strLogonName)
        {
            int intRowsAffected = 0;
            intRowsAffected = objDAUM.CheckUserLogonName(strLogonName);
            if (intRowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool CheckAdminUser()
        {
            int intRowCount = 0;
            intRowCount = objDAUM.CheckAdminUser().Tables[0].Rows.Count;
            if (intRowCount >= 6)
            {
                return true;
            }
            else 
            {
                return false;
            }

        }

        //Get login User
        public object GetLoginUser(string strLogonName)
        {
            return objDAUM.GetLoginUser(strLogonName);
        }
    }
}
